Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storing previous randomness values #1197

Merged
merged 27 commits into from
Oct 25, 2019

Conversation

mrsmkl
Copy link
Contributor

@mrsmkl mrsmkl commented Oct 3, 2019

Description

Just stores the randomness value to a mapping. If it is too much overhead to store it for all blocks, it can be easily changed to just store N previous blocks.

Tested

I didn't see any tests related to randomness.

Other changes

Related issues

Backwards compatibility

@nambrot
Copy link
Contributor

nambrot commented Oct 4, 2019

Thanks for the PR @mrsmkl !

We are currently still discussing the specific change, but I can tell you that we can't store the whole history for sure. Ill update here once that is the case!

@asaj
Copy link
Contributor

asaj commented Oct 8, 2019

I didn't see any tests related to randomness.

Would you mind adding some? I suspect we don't have them because of the require(msg.sender == address(0)) but this is easily worked around.

We can define an internal function that has all of the business logic, and then expose it in an external function that just requires msg.sender == address(0) and then calls the internal function.

Then, for testing, we can create contracts/identity/test/RandomTest.sol that inherits from Random and exposes the internal function.

Here's an example for Validators, which will soon have the same issue:
https://github.com/celo-org/celo-monorepo/blob/asaj/pos-2/packages/protocol/contracts/governance/Validators.sol#L439
https://github.com/celo-org/celo-monorepo/blob/asaj/pos-2/packages/protocol/contracts/governance/test/ValidatorsTest.sol
https://github.com/celo-org/celo-monorepo/blob/asaj/pos-2/packages/protocol/test/governance/validators.ts#L1352

@codecov
Copy link

codecov bot commented Oct 9, 2019

Codecov Report

Merging #1197 into master will increase coverage by 1.76%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1197      +/-   ##
=========================================
+ Coverage   65.33%   67.1%   +1.76%     
=========================================
  Files         271     266       -5     
  Lines        8184    7776     -408     
  Branches      570     444     -126     
=========================================
- Hits         5347    5218     -129     
+ Misses       2716    2458     -258     
+ Partials      121     100      -21
Flag Coverage Δ
#mobile 67.1% <ø> (+1.76%) ⬆️
Impacted Files Coverage Δ
packages/mobile/src/exchange/actions.ts 28.15% <0%> (-71.85%) ⬇️
packages/mobile/src/pincode/PincodeCache.ts 37.5% <0%> (-25%) ⬇️
packages/mobile/src/firebase/firebase.ts 20.89% <0%> (-21.33%) ⬇️
packages/mobile/src/backup/utils.ts 70.73% <0%> (-11.63%) ⬇️
packages/mobile/src/exchange/reducer.ts 60% <0%> (-6.67%) ⬇️
packages/mobile/src/utils/AppRestart.ts 50% <0%> (-6.25%) ⬇️
packages/mobile/src/import/reducer.ts 37.5% <0%> (-5.36%) ⬇️
packages/mobile/src/firebase/notifications.ts 40.54% <0%> (-5.18%) ⬇️
packages/mobile/src/backup/BackupComplete.tsx 81.25% <0%> (-4.47%) ⬇️
packages/mobile/src/redux/store.ts 96% <0%> (-4%) ⬇️
... and 80 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 947e237...a488cd5. Read the comment docs.

@nambrot nambrot assigned asaj and unassigned nambrot Oct 10, 2019
packages/protocol/contracts/identity/Random.sol Outdated Show resolved Hide resolved
@@ -13,7 +13,18 @@ contract Random is IRandom {

bytes32 public _random;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this now redundant with history?

packages/protocol/contracts/identity/Random.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Random.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Random.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Random.sol Outdated Show resolved Hide resolved
packages/protocol/test/identity/random.ts Outdated Show resolved Hide resolved
packages/protocol/test/identity/random.ts Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Random.sol Outdated Show resolved Hide resolved
@asaj asaj assigned mrsmkl and unassigned asaj Oct 10, 2019
@asaj
Copy link
Contributor

asaj commented Oct 10, 2019

For some reason the end-to-end transfer tests appear to be failing..

@nambrot nambrot mentioned this pull request Oct 14, 2019
3 tasks
@mrsmkl mrsmkl assigned asaj and nambrot and unassigned mrsmkl Oct 15, 2019
Copy link
Contributor

@asaj asaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nits

packages/protocol/contracts/identity/Random.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Random.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/test/TestRandom.sol Outdated Show resolved Hide resolved
packages/protocol/test/identity/random.ts Show resolved Hide resolved
packages/protocol/contracts/identity/Random.sol Outdated Show resolved Hide resolved
packages/protocol/migrationsConfig.js Show resolved Hide resolved
@asaj asaj assigned mrsmkl and unassigned asaj Oct 17, 2019
@mrsmkl mrsmkl assigned asaj and unassigned mrsmkl Oct 18, 2019
README-dev.md Outdated
2. Exception to (1) are packages that represent a GAE/firebase app which must use the last published version.
3. To differentiate published vs unpublished version. Master version (in package.json) must end with suffix `-dev` and should not be published.
4. If a developer want to publish a version; then after publishing it needs to set master version to next `-dev` version and change all package.json that require on it.
1. All packages must use **master version** of sibling packages.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were the changes to the readmes intentional? If not, please revert.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder where this came from...

@asaj asaj assigned mrsmkl and unassigned asaj Oct 18, 2019
@mrsmkl mrsmkl added the automerge Have PR merge automatically when checks pass label Oct 18, 2019
@nambrot nambrot removed the automerge Have PR merge automatically when checks pass label Oct 18, 2019
@nambrot
Copy link
Contributor

nambrot commented Oct 18, 2019

Let's hold off on merging this until we cut for Alfajores deploy since this is breaking mobile clients

@asaj asaj self-assigned this Oct 25, 2019
@asaj asaj added the automerge Have PR merge automatically when checks pass label Oct 25, 2019
@celo-ci-bot-user celo-ci-bot-user merged commit e153a29 into celo-org:master Oct 25, 2019
aaronmgdr added a commit that referenced this pull request Oct 29, 2019
…repo into aaronmgdr/invite-page

* 'aaronmgdr/invite-page' of github.com:celo-org/celo-monorepo: (63 commits)
  Fix compile error during local clean build (#1506)
  Update to RN 61 and AndroidX (#1343)
  Set usage of shuffled round robin in the genesis block (#1464)
  Add spanish backup key for backup key flow (#1500)
  Fix sync tests by pulling genesis block to determine epoch length (#1504)
  [Wallet] fix missing full name error alert (#1496)
  [Wallet + Verification Pool] Add details about generating an app-signature (#1482)
  Deploy celo's image of ethstats (#1421)
  Storing previous randomness values (#1197)
  [Wallet] Fix wei invite bug (#1489)
  Point all packages to latest ganache-cli master (#1488)
  Point end-to-end tests back to master (#1469)
  [Wallet] Migrate app view functions to contractkit (#1381)
  [Wallet] Add script to translate locale strings (#1485)
  [Wallet] Update wallet celo client version and add missing translations for backup flow (#1483)
  [Wallet] Hotfix local currency (#1481)
  [Wallet] Remove QR debouncing to improve responsiveness (#1480)
  [Wallet] Upgrade app version to v1.5.1 (#1463)
  Update governance end-to-end tests to work with changed precompile (#1476)
  Fixes key_placer.sh when encrypting files (#1465)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Developers SBAT have access to randomness of prior blocks
4 participants